﻿#pragma once
#include "./_private/_privateinc.h"
#include "../logger.h"
#include "logbase.h"
#include <mutex>
#include <condition_variable>

NAMESPACE_BEG
class LoggerPrintMgr {
public:
	static LoggerPrintMgr& getInstance () {
		static LoggerPrintMgr mgr;
		return mgr;
	}
	~LoggerPrintMgr ();
	void postLog (const logger::LogItem& logger);
	void addLogDevice(int device) {
		if (log_device_ == device)
			return;
		log_device_ = device;
	}
	void openLogQue(bool open_log_que) { open_log_que_ = open_log_que; }

	inline void setLogLevel(int level) {level_ = level;}
private:
	void _run ();
	LoggerPrintMgr ();

private:
	int         level_=31;
	int         log_device_ = (int)LOG_DEVICE::DEVICE_CONSL;
	std::mutex  mtx_;
	std::condition_variable cv_;
	std::deque<LogItem> logger_que_;
	bool        open_log_que_=true;

};
NAMESPACE_END
